<template lang='pug'>
  .page
    .search-form
      Row(type="flex" justify="start" :gutter="16")
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 上级公司：
          Input(v-model="searchData.ParentCompanyName" placeholder="请输入" clearable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 客户名称：
          Input(v-model="searchData.CustomerName" placeholder="请输入" clearable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 合作类型：
          Select(v-model="searchData.CooperateType" placeholder="请选择" clearable)
            Option(v-for="item in CooperateTypeArr" :value="item.key" :key="item.key") {{ item.value }}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 合作状态：
          Select(v-model="searchData.Status" placeholder="请选择" clearable)
            Option(v-for="item in StatusArr" :value="item.key" :key="item.key") {{ item.value }}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 所属客服：
          Select(v-model="searchData.ServerId" placeholder="请选择所属客服" filterable clearable)
            Option(v-for="(item, index) in servers" :value="item.key" :key="index") {{ item.value }}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 续约状态：
          Select(v-model="searchData.RenewalStatus" placeholder="请选择" clearable)
            Option(v-for="item in RenewalStatusArr" :value="item.value" :key="item.value") {{item.label}}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 到期时间：
          Select(v-model="searchData.RenewalMonth" placeholder="请选择" clearable)
            Option(v-for="item in RenewalMonthArr" :value="item.value" :key="item.value") {{item.text}}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 姓名：
          Input(v-model="searchData.Name"  placeholder="请输入" clearable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w100 身份证号码：
          Input(v-model="searchData.IdCardNo" placeholder="请输入" clearable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 在职状态：
          Select(v-model="searchData.BeHiringName" placeholder="请选择" clearable)
            Option(v-for="item in BeHiringNameArr" :value="item.value" :key="item.value") {{item.label}}
          Button.ml-15(v-if="hasFind" type="info" @click="searchBtn") 查询
    .pl-20.pr-20.bg-white
      Table.hasTitle-table.beautiful-table(:columns="thead" :data="tableData" :loading="loading" @on-selection-change="onSelectChange" :stripe="true")
        ._table_header(slot="header")
          .table-title-lefttxt.pull-left
            span.leftText
              | 合计:
              span.text-info.pl-5.pr-5.font-weight {{totalRows}}
          .pull-right.table-title-btns
            i-button.mr-10(v-if="hasExport" type="info" @click="exportBtn") 导出
        ._table_footer(slot="footer")
          //- span 共{{totalRows}}条
          template
            Page(class="_page" :total="totalRows" :current="searchData.PageIndex" prev-text="上一页" next-text="下一页" @on-change="onChangePage" @on-page-size-change="onpageSizeChange" show-sizer show-total :page-size-opts="[10, 20, 30, 50, 100]")
    //- 单位调离
</template>

<script>
// import dataApi from '@/api/data.js'
import Mixin from '../mixin.js'
import RiskWarnApi from '../service.js'

export default {
  name:'staff-contract-monitor',
  props:{},
  mixins: [Mixin],
  data () {
    return {
      thead: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '上级公司',
          minWidth: 150,
          align: 'center',
          key: 'parentCompanyName'
        },
        {
          title: '客户名称',
          minWidth: 150,
          align: 'center',
          key: 'customerName'
        },
        {
          title: '合作类型',
          minWidth: 100,
          align: 'center',
          key: 'typeName'
        },
        {
          title: '合作状态',
          minWidth: 100,
          align: 'center',
          key: 'statusName'
        },
        {
          title: '所属客服',
          minWidth: 100,
          align: 'center',
          key: 'serverName'
        },
        {
          title: '姓名',
          minWidth: 100,
          align: 'center',
          key: 'name'
        },
        {
          title: '身份证号码',
          minWidth: 190,
          align: 'center',
          key: 'idCardNo'
        },
        {
          title: '在职状态',
          minWidth: 120,
          align: 'center',
          key: 'beHiringName'
        },
        {
          title: '年龄',
          minWidth: 90,
          align: 'center',
          key: 'age'
        },
        {
          title: '部门',
          minWidth: 100,
          align: 'center',
          key: 'department'
        },
        {
          title: '职位',
          minWidth: 120,
          align: 'center',
          key: 'duty'
        },
        {
          title: '用工形式',
          minWidth: 100,
          align: 'center',
          key: 'employeeTypeName'
        },
        {
          title: '入职时间',
          minWidth: 150,
          align: 'center',
          key: 'onBoardingDate',
          render: (h, params) => {
            let row = params.row
            let times = ''
            if (row.onBoardingDate) {
              times = row.onBoardingDate.slice(0, 10)
            }
            return h('span', times)
          }
        },
        {
          title: '开始时间',
          minWidth: 150,
          align: 'center',
          key: 'startDate',
          render: (h, params) => {
            let row = params.row
            let times = ''
            if (row.startDate) {
              times = row.startDate.slice(0, 10)
            }
            return h('span', times)
          }
        },
        {
          title: '结束时间',
          minWidth: 150,
          align: 'center',
          key: 'endDate',
          render: (h, params) => {
            let row = params.row
            let times = ''
            if (row.endDate) {
              times = row.endDate.slice(0, 10)
            }
            return h('span', times)
          }
        },
        {
          title: '到期时间',
          minWidth: 120,
          align: 'center',
          key: 'renewalMonthName'
        },
        {
          title: '续约状态',
          minWidth: 120,
          align: 'center',
          key: 'renewalStatusName'
        }
      ]

    }
  },

  components: {},

  computed: {
  },

  beforeMount() {},

  mounted() {
    // this.getFirstParentCompanys(1)
    this.getListData()
  },

  methods: {
    getListData () {
      this.loading = true
      RiskWarnApi.EmployeeContractList(Object.assign({SearchType: 1}, this.searchData )).then(res => {
        this.loading = false
        if (res.data.success) {
          this.tableData = res.data.data
          this.totalRows = res.data.totalRows
        } else {
          this.$Message.error(res.data.message)
        }
        
      })
    },
    searchBtn () {
      this.searchData.PageIndex = 1
      this.getListData()
    },
    exportBtn () {
      RiskWarnApi.EmployeeContractExport(Object.assign({Ids: this.Ids,SearchType: 1},this.searchData)).then(res => {
        if (res.data.success) {
          let objectUrl = res.data.data
          const link = document.createElement('a')
          link.download = ''
          link.href = objectUrl
          link.click()
        } else {
          this.$Message.error(res.data.message)
        }
      })
    },
  },

  watch: {}

}

</script>
<style lang='less' scoped>

</style>